package cn.itcast.mqtest;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.Test;

public class MQProducter {
	
	
	@Test
	public void producter() throws JMSException{
		
		ConnectionFactory factory = new ActiveMQConnectionFactory();
		Connection connection = factory.createConnection();
		connection.start();
		Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		Queue queue = session.createQueue("helloword");
		MessageProducer producer = session.createProducer(queue);
		for (int i = 0; i < 10; i++) {
		producer.send(session.createTextMessage("消息"+i));
		
		}
	}
}
